/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.delaphone.flocash.web.action;

import com.delaphone.flocash.model.FBanks;
import com.delaphone.flocash.model.FCards;
import com.delaphone.flocash.model.FUser;
import com.delaphone.flocash.service.BankService;
import com.delaphone.flocash.service.UserService;
import com.opensymphony.xwork2.Action;
import java.util.List;

/**
 *
 * @author tamdx
 */
public class ProfileAction extends BaseAction {

    private UserService userService;
    private BankService bankService;
    private String firstname;
    private String lastname;
    private String address;
    private String city;
    private String postal_code;
    private String state;
    private String country;
    private String email;
    private String accType;
    private String phone;
    private String msg;
    private List<FCards> listCard;
    private List<FBanks> listBank;

    public String index() {
        if (user == null) {
            return Action.ERROR;
        }
        FUser u = userService.getUserByEmail(user.getEmail());
        if (u != null) {
            setFirstname(u.getFirstName());
            setLastname(u.getLastName());
            setAddress(u.getAddress());
            setCity(u.getCity());
            setPostal_code(u.getPostalCode());
            setState(u.getState());
            setCountry(u.getCountryCode());
            setEmail(u.getEmail());
            setAccType(u.getAccountType());
            setPhone(u.getPhoneNumber());
        }
        listCard = bankService.getListCardByUserId(user.getId());
        listBank = bankService.getListBankByUserId(user.getId());

        return Action.INPUT;
    }

    // <editor-fold defaultstate="collapsed" desc="set and get method">
    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public BankService getBankService() {
        return bankService;
    }

    public void setBankService(BankService bankService) {
        this.bankService = bankService;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List<FCards> getListCard() {
        return listCard;
    }

    public void setListCard(List<FCards> listCard) {
        this.listCard = listCard;
    }

    public List<FBanks> getListBank() {
        return listBank;
    }

    public void setListBank(List<FBanks> listBank) {
        this.listBank = listBank;
    }

    

    public String getAccType() {
        return accType;
    }

    public void setAccType(String accType) {
        this.accType = accType;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPostal_code() {
        return postal_code;
    }

    public void setPostal_code(String postal_code) {
        this.postal_code = postal_code;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }// </editor-fold>
}
